package com.usian.controller;

import com.usian.pojo.TbContent;
import com.usian.pojo.TbContentCategory;
import com.usian.service.TbConService;
import com.usian.utils.AdNode;
import com.usian.utils.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ContentController {
    @Autowired
    private TbConService tbConService;


    @RequestMapping("selectContentCategoryByParentId")
    public List<TbContentCategory> selectContentCategoryByParentId(@RequestParam Integer id){
        return tbConService.selectContentCategoryByParentId(id);
    }

    @RequestMapping("insertContentCategory")
    public int insertContentCategory(@RequestParam Integer parentId,@RequestParam String name){
        return tbConService.insertContentCategory(parentId,name);
    };

    @RequestMapping("deleteContentCategoryById")
    public void deleteContentCategoryById(@RequestParam long categoryId){
         tbConService.deleteContentCategoryById(categoryId);
    };
    @RequestMapping("updateContentCategory")
    public int updateContentCategory(@RequestParam Integer id,@RequestParam String name){
        return tbConService.updateContentCategory(id,name);
    };

    @RequestMapping("selectTbContentAllByCategoryId")
    public PageResult selectTbContentAllByCategoryId(@RequestParam long categoryId){
        return tbConService.selectTbContentAllByCategoryId(categoryId);
    };

    @RequestMapping("insertTbContent")
    public int insertTbContent(@RequestBody TbContent tbContent){
        return tbConService.insertTbContent(tbContent);
    };

    @RequestMapping("deleteContentByIds")
    public int deleteContentByIds(@RequestParam long ids){
        return tbConService.deleteContentByIds(ids);
    };

    @RequestMapping("selectFrontendContentByAD")
    public List<AdNode> selectFrontendContentByAD(){
        return tbConService.selectFrontendContentByAD();
    };

}
